package com.sc.justification.system;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BeanProperty;
import org.jdesktop.beansbinding.BindingGroup;
import org.jdesktop.beansbinding.Bindings;

public class InstitutePanel2 extends JPanel {

	private BindingGroup m_bindingGroup;
	private com.sc.justification.model.Institute institute = new com.sc.justification.model.Institute();
	private JTextField accountJTextField;
	private JTextField accountNameJTextField;
	private JTextField addressJTextField;
	private JTextField authorityJTextField;
	private JTextField businessScopeJTextField;
	private JTextField cellphoneJTextField;
	private JTextField emailJTextField;
	private JTextField faxJTextField;
	private JTextField idJTextField;
	private JTextField instituteNameJTextField;
	private JTextField legalRepresentitiveJTextField;
	private JTextField lisenceNoJTextField;
	private JTextField openingBankJTextField;
	private JTextField telJTextField;
	private JTextField websiteJTextField;
	private JTextField zipcodeJTextField;

	public InstitutePanel2(com.sc.justification.model.Institute newInstitute) {
		this();
		setInstitute(newInstitute);
	}

	public InstitutePanel2() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[] { 0, 0, 0 };
		gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0 };
		gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 1.0E-4 };
		gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
				0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
		setLayout(gridBagLayout);

		JLabel accountLabel = new JLabel("Account:");
		GridBagConstraints labelGbc_0 = new GridBagConstraints();
		labelGbc_0.insets = new Insets(5, 5, 5, 5);
		labelGbc_0.gridx = 0;
		labelGbc_0.gridy = 0;
		add(accountLabel, labelGbc_0);

		accountJTextField = new JTextField();
		GridBagConstraints componentGbc_0 = new GridBagConstraints();
		componentGbc_0.insets = new Insets(5, 0, 5, 5);
		componentGbc_0.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_0.gridx = 1;
		componentGbc_0.gridy = 0;
		add(accountJTextField, componentGbc_0);

		JLabel accountNameLabel = new JLabel("AccountName:");
		GridBagConstraints labelGbc_1 = new GridBagConstraints();
		labelGbc_1.insets = new Insets(5, 5, 5, 5);
		labelGbc_1.gridx = 0;
		labelGbc_1.gridy = 1;
		add(accountNameLabel, labelGbc_1);

		accountNameJTextField = new JTextField();
		GridBagConstraints componentGbc_1 = new GridBagConstraints();
		componentGbc_1.insets = new Insets(5, 0, 5, 5);
		componentGbc_1.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_1.gridx = 1;
		componentGbc_1.gridy = 1;
		add(accountNameJTextField, componentGbc_1);

		JLabel addressLabel = new JLabel("Address:");
		GridBagConstraints labelGbc_2 = new GridBagConstraints();
		labelGbc_2.insets = new Insets(5, 5, 5, 5);
		labelGbc_2.gridx = 0;
		labelGbc_2.gridy = 2;
		add(addressLabel, labelGbc_2);

		addressJTextField = new JTextField();
		GridBagConstraints componentGbc_2 = new GridBagConstraints();
		componentGbc_2.insets = new Insets(5, 0, 5, 5);
		componentGbc_2.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_2.gridx = 1;
		componentGbc_2.gridy = 2;
		add(addressJTextField, componentGbc_2);

		JLabel authorityLabel = new JLabel("Authority:");
		GridBagConstraints labelGbc_3 = new GridBagConstraints();
		labelGbc_3.insets = new Insets(5, 5, 5, 5);
		labelGbc_3.gridx = 0;
		labelGbc_3.gridy = 3;
		add(authorityLabel, labelGbc_3);

		authorityJTextField = new JTextField();
		GridBagConstraints componentGbc_3 = new GridBagConstraints();
		componentGbc_3.insets = new Insets(5, 0, 5, 5);
		componentGbc_3.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_3.gridx = 1;
		componentGbc_3.gridy = 3;
		add(authorityJTextField, componentGbc_3);

		JLabel businessScopeLabel = new JLabel("BusinessScope:");
		GridBagConstraints labelGbc_4 = new GridBagConstraints();
		labelGbc_4.insets = new Insets(5, 5, 5, 5);
		labelGbc_4.gridx = 0;
		labelGbc_4.gridy = 4;
		add(businessScopeLabel, labelGbc_4);

		businessScopeJTextField = new JTextField();
		GridBagConstraints componentGbc_4 = new GridBagConstraints();
		componentGbc_4.insets = new Insets(5, 0, 5, 5);
		componentGbc_4.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_4.gridx = 1;
		componentGbc_4.gridy = 4;
		add(businessScopeJTextField, componentGbc_4);

		JLabel cellphoneLabel = new JLabel("Cellphone:");
		GridBagConstraints labelGbc_5 = new GridBagConstraints();
		labelGbc_5.insets = new Insets(5, 5, 5, 5);
		labelGbc_5.gridx = 0;
		labelGbc_5.gridy = 5;
		add(cellphoneLabel, labelGbc_5);

		cellphoneJTextField = new JTextField();
		GridBagConstraints componentGbc_5 = new GridBagConstraints();
		componentGbc_5.insets = new Insets(5, 0, 5, 5);
		componentGbc_5.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_5.gridx = 1;
		componentGbc_5.gridy = 5;
		add(cellphoneJTextField, componentGbc_5);

		JLabel emailLabel = new JLabel("Email:");
		GridBagConstraints labelGbc_6 = new GridBagConstraints();
		labelGbc_6.insets = new Insets(5, 5, 5, 5);
		labelGbc_6.gridx = 0;
		labelGbc_6.gridy = 6;
		add(emailLabel, labelGbc_6);

		emailJTextField = new JTextField();
		GridBagConstraints componentGbc_6 = new GridBagConstraints();
		componentGbc_6.insets = new Insets(5, 0, 5, 5);
		componentGbc_6.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_6.gridx = 1;
		componentGbc_6.gridy = 6;
		add(emailJTextField, componentGbc_6);

		JLabel faxLabel = new JLabel("Fax:");
		GridBagConstraints labelGbc_7 = new GridBagConstraints();
		labelGbc_7.insets = new Insets(5, 5, 5, 5);
		labelGbc_7.gridx = 0;
		labelGbc_7.gridy = 7;
		add(faxLabel, labelGbc_7);

		faxJTextField = new JTextField();
		GridBagConstraints componentGbc_7 = new GridBagConstraints();
		componentGbc_7.insets = new Insets(5, 0, 5, 5);
		componentGbc_7.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_7.gridx = 1;
		componentGbc_7.gridy = 7;
		add(faxJTextField, componentGbc_7);

		JLabel idLabel = new JLabel("Id:");
		GridBagConstraints labelGbc_8 = new GridBagConstraints();
		labelGbc_8.insets = new Insets(5, 5, 5, 5);
		labelGbc_8.gridx = 0;
		labelGbc_8.gridy = 8;
		add(idLabel, labelGbc_8);

		idJTextField = new JTextField();
		GridBagConstraints componentGbc_8 = new GridBagConstraints();
		componentGbc_8.insets = new Insets(5, 0, 5, 5);
		componentGbc_8.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_8.gridx = 1;
		componentGbc_8.gridy = 8;
		add(idJTextField, componentGbc_8);

		JLabel instituteNameLabel = new JLabel("InstituteName:");
		GridBagConstraints labelGbc_9 = new GridBagConstraints();
		labelGbc_9.insets = new Insets(5, 5, 5, 5);
		labelGbc_9.gridx = 0;
		labelGbc_9.gridy = 9;
		add(instituteNameLabel, labelGbc_9);

		instituteNameJTextField = new JTextField();
		GridBagConstraints componentGbc_9 = new GridBagConstraints();
		componentGbc_9.insets = new Insets(5, 0, 5, 5);
		componentGbc_9.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_9.gridx = 1;
		componentGbc_9.gridy = 9;
		add(instituteNameJTextField, componentGbc_9);

		JLabel legalRepresentitiveLabel = new JLabel("LegalRepresentitive:");
		GridBagConstraints labelGbc_10 = new GridBagConstraints();
		labelGbc_10.insets = new Insets(5, 5, 5, 5);
		labelGbc_10.gridx = 0;
		labelGbc_10.gridy = 10;
		add(legalRepresentitiveLabel, labelGbc_10);

		legalRepresentitiveJTextField = new JTextField();
		GridBagConstraints componentGbc_10 = new GridBagConstraints();
		componentGbc_10.insets = new Insets(5, 0, 5, 5);
		componentGbc_10.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_10.gridx = 1;
		componentGbc_10.gridy = 10;
		add(legalRepresentitiveJTextField, componentGbc_10);

		JLabel lisenceNoLabel = new JLabel("LisenceNo:");
		GridBagConstraints labelGbc_11 = new GridBagConstraints();
		labelGbc_11.insets = new Insets(5, 5, 5, 5);
		labelGbc_11.gridx = 0;
		labelGbc_11.gridy = 11;
		add(lisenceNoLabel, labelGbc_11);

		lisenceNoJTextField = new JTextField();
		GridBagConstraints componentGbc_11 = new GridBagConstraints();
		componentGbc_11.insets = new Insets(5, 0, 5, 5);
		componentGbc_11.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_11.gridx = 1;
		componentGbc_11.gridy = 11;
		add(lisenceNoJTextField, componentGbc_11);

		JLabel openingBankLabel = new JLabel("OpeningBank:");
		GridBagConstraints labelGbc_12 = new GridBagConstraints();
		labelGbc_12.insets = new Insets(5, 5, 5, 5);
		labelGbc_12.gridx = 0;
		labelGbc_12.gridy = 12;
		add(openingBankLabel, labelGbc_12);

		openingBankJTextField = new JTextField();
		GridBagConstraints componentGbc_12 = new GridBagConstraints();
		componentGbc_12.insets = new Insets(5, 0, 5, 5);
		componentGbc_12.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_12.gridx = 1;
		componentGbc_12.gridy = 12;
		add(openingBankJTextField, componentGbc_12);

		JLabel telLabel = new JLabel("Tel:");
		GridBagConstraints labelGbc_13 = new GridBagConstraints();
		labelGbc_13.insets = new Insets(5, 5, 5, 5);
		labelGbc_13.gridx = 0;
		labelGbc_13.gridy = 13;
		add(telLabel, labelGbc_13);

		telJTextField = new JTextField();
		GridBagConstraints componentGbc_13 = new GridBagConstraints();
		componentGbc_13.insets = new Insets(5, 0, 5, 5);
		componentGbc_13.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_13.gridx = 1;
		componentGbc_13.gridy = 13;
		add(telJTextField, componentGbc_13);

		JLabel websiteLabel = new JLabel("Website:");
		GridBagConstraints labelGbc_14 = new GridBagConstraints();
		labelGbc_14.insets = new Insets(5, 5, 5, 5);
		labelGbc_14.gridx = 0;
		labelGbc_14.gridy = 14;
		add(websiteLabel, labelGbc_14);

		websiteJTextField = new JTextField();
		GridBagConstraints componentGbc_14 = new GridBagConstraints();
		componentGbc_14.insets = new Insets(5, 0, 5, 5);
		componentGbc_14.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_14.gridx = 1;
		componentGbc_14.gridy = 14;
		add(websiteJTextField, componentGbc_14);

		JLabel zipcodeLabel = new JLabel("Zipcode:");
		GridBagConstraints labelGbc_15 = new GridBagConstraints();
		labelGbc_15.insets = new Insets(5, 5, 5, 5);
		labelGbc_15.gridx = 0;
		labelGbc_15.gridy = 15;
		add(zipcodeLabel, labelGbc_15);

		zipcodeJTextField = new JTextField();
		GridBagConstraints componentGbc_15 = new GridBagConstraints();
		componentGbc_15.insets = new Insets(5, 0, 5, 5);
		componentGbc_15.fill = GridBagConstraints.HORIZONTAL;
		componentGbc_15.gridx = 1;
		componentGbc_15.gridy = 15;
		add(zipcodeJTextField, componentGbc_15);

		if (institute != null) {
			m_bindingGroup = initDataBindings();
		}
	}

	protected BindingGroup initDataBindings() {
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> accountProperty = BeanProperty
				.create("account");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						accountProperty, accountJTextField, textProperty);
		autoBinding.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> accountNameProperty = BeanProperty
				.create("accountName");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_1 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_1 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						accountNameProperty, accountNameJTextField,
						textProperty_1);
		autoBinding_1.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> addressProperty = BeanProperty
				.create("address");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_2 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_2 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						addressProperty, addressJTextField, textProperty_2);
		autoBinding_2.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> authorityProperty = BeanProperty
				.create("authority");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_3 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_3 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						authorityProperty, authorityJTextField, textProperty_3);
		autoBinding_3.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> businessScopeProperty = BeanProperty
				.create("businessScope");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_4 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_4 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						businessScopeProperty, businessScopeJTextField,
						textProperty_4);
		autoBinding_4.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> cellphoneProperty = BeanProperty
				.create("cellphone");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_5 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_5 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						cellphoneProperty, cellphoneJTextField, textProperty_5);
		autoBinding_5.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> emailProperty = BeanProperty
				.create("email");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_6 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_6 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						emailProperty, emailJTextField, textProperty_6);
		autoBinding_6.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> faxProperty = BeanProperty
				.create("fax");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_7 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_7 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						faxProperty, faxJTextField, textProperty_7);
		autoBinding_7.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> idProperty = BeanProperty
				.create("id");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_8 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_8 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						idProperty, idJTextField, textProperty_8);
		autoBinding_8.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> instituteNameProperty = BeanProperty
				.create("instituteName");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_9 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_9 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						instituteNameProperty, instituteNameJTextField,
						textProperty_9);
		autoBinding_9.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> legalRepresentitiveProperty = BeanProperty
				.create("legalRepresentitive");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_10 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_10 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						legalRepresentitiveProperty,
						legalRepresentitiveJTextField, textProperty_10);
		autoBinding_10.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> lisenceNoProperty = BeanProperty
				.create("lisenceNo");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_11 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_11 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						lisenceNoProperty, lisenceNoJTextField, textProperty_11);
		autoBinding_11.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> openingBankProperty = BeanProperty
				.create("openingBank");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_12 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_12 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						openingBankProperty, openingBankJTextField,
						textProperty_12);
		autoBinding_12.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> telProperty = BeanProperty
				.create("tel");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_13 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_13 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						telProperty, telJTextField, textProperty_13);
		autoBinding_13.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> websiteProperty = BeanProperty
				.create("website");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_14 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_14 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						websiteProperty, websiteJTextField, textProperty_14);
		autoBinding_14.bind();
		//
		BeanProperty<com.sc.justification.model.Institute, java.lang.String> zipcodeProperty = BeanProperty
				.create("zipcode");
		BeanProperty<javax.swing.JTextField, java.lang.String> textProperty_15 = BeanProperty
				.create("text");
		AutoBinding<com.sc.justification.model.Institute, java.lang.String, javax.swing.JTextField, java.lang.String> autoBinding_15 = Bindings
				.createAutoBinding(AutoBinding.UpdateStrategy.READ, institute,
						zipcodeProperty, zipcodeJTextField, textProperty_15);
		autoBinding_15.bind();
		//
		BindingGroup bindingGroup = new BindingGroup();
		bindingGroup.addBinding(autoBinding);
		bindingGroup.addBinding(autoBinding_1);
		bindingGroup.addBinding(autoBinding_2);
		bindingGroup.addBinding(autoBinding_3);
		bindingGroup.addBinding(autoBinding_4);
		bindingGroup.addBinding(autoBinding_5);
		bindingGroup.addBinding(autoBinding_6);
		bindingGroup.addBinding(autoBinding_7);
		bindingGroup.addBinding(autoBinding_8);
		bindingGroup.addBinding(autoBinding_9);
		bindingGroup.addBinding(autoBinding_10);
		bindingGroup.addBinding(autoBinding_11);
		bindingGroup.addBinding(autoBinding_12);
		bindingGroup.addBinding(autoBinding_13);
		bindingGroup.addBinding(autoBinding_14);
		bindingGroup.addBinding(autoBinding_15);
		//
		return bindingGroup;
	}

	public com.sc.justification.model.Institute getInstitute() {
		return institute;
	}

	public void setInstitute(com.sc.justification.model.Institute newInstitute) {
		setInstitute(newInstitute, true);
	}

	public void setInstitute(com.sc.justification.model.Institute newInstitute,
			boolean update) {
		institute = newInstitute;
		if (update) {
			if (m_bindingGroup != null) {
				m_bindingGroup.unbind();
				m_bindingGroup = null;
			}
			if (institute != null) {
				m_bindingGroup = initDataBindings();
			}
		}
	}

}
